//
// Description: 5928. 解码斜向换位密码
// Created by Loading on 2021/11/14.
//

#include <bits/stdc++.h>

using namespace std;

string decodeCiphertext(string encodedText, int rows) {
    int n = encodedText.size();
    int cols = n / rows;
    string res;

    for (int i = 0; i < cols; ++i) {
        for (int j = 0; j < rows; ++j) {
            // 偏移量
            int offset = j * (cols + 1) + i;
            if (offset < n) {
                res += encodedText[offset];
            } else {
                break;
            }
        }
    }
    // 去掉末尾的空格
    while (res.back() == ' ') {
        res.pop_back();
    }

    return res;
}

int main() {
    string encodedText = "iveo    eed   l te   olc";
    int rows = 4;
    string res = decodeCiphertext(encodedText, rows);
    cout << res << endl;

    return 0;
}